package com.example.lib;

public class DuckBehaviorTest {
    public static void main(String[] args) {
        // 基础行为测试
        testDuck(new MallardDuck(),   "标准绿头鸭");
        testDuck(new RedheadDuck(),  "稀有红头鸭");
        testDuck(new RubberDuck(),    "浴室橡皮鸭");
        testDuck(new DecoyDuck(),     "狩猎诱饵鸭");

        // 动态行为替换测试
        Duck mutantDuck = new RubberDuck();
        mutantDuck.setFlyBehavior(new FlyWithWings());
        mutantDuck.setQuackBehavior(new Quack());

        System.out.println("\n=== 变异橡皮鸭 ===");
        mutantDuck.performFly();
        mutantDuck.performQuack();
    }

    private static void testDuck(Duck duck, String tag) {
        System.out.println("\n测试对象: " + tag);
        duck.display();
        duck.swim();
        System.out.print("飞行测试: ");
        duck.performFly();
        System.out.print("叫声测试: ");
        duck.performQuack();
    }
}